
import { Button, Tabs,Modal} from 'antd';
import React, { useState,} from 'react';
import axios from 'axios';
import 'antd/dist/antd.css';
import '../view/css/bg_rw.css'
import './css/bg_rz.css'
import Bg_rz_qb from './bg_rz_qb'
import Bg_rz_wd from './bg_rz_wd'
import Bg_rz_sd from './bg_rz_sd'
import Bg_rz_fc from './bg_rz_fc'
//import { Select } from 'antd';
//const { Option } = Select;
const { TabPane } = Tabs;


let Bg_rz = function(){
    const [visible, setVisible] = useState(false);
    const [data1,setData1] = useState([])
    const [val,setval] = useState('')
    const [val1,setval1] = useState('')
    const [val2,setval2] = useState('')
    var index=''
    
    function callback(key) {
        index=key
        console.log(key);
    }
    function valchange(event){
        let str = event.target.value
        console.log(str);
        setval(str)
    }
    function valchange1(event){
        let str1 = event.target.value
        console.log(str1);
        setval1(str1)
    }
    function valchange2(event){
        let str2 = event.target.value
        console.log(str2);
        setval2(str2)
    }
    
    function ry(){
        const FetchData = async () => {
            const result = await axios.post(
                'http://crm.cimns.com/index.php/admin/users/getUserList'
            );
            
            setData1(result.data.data)
        };
        FetchData();
        
        
    }
    function fs(){
        setVisible(false)
        const FetchData = async () => {
            const result = await axios.post(
                'http://crm.cimns.com/index.php/oa/log/save',{
                    category_id: index,
                    content: val,
                    tomorrow: val1,
                    question: val2,
                }
            );
            window.location.reload();
        };
        FetchData();
    }
    
    return(
        <div className="gg">
            <div>
                <div className="new-wrap">
                    <Button><a type="primary" onClick={() =>{setVisible(true);ry()} }>新建任务</a></Button>
                </div>
                <Tabs defaultActiveKey="1" onChange={callback} addIcon={<Button>111111</Button>}>
                
                    <TabPane tab="全部" key="1">
                        <Bg_rz_qb/>
                    </TabPane>
                    <TabPane tab="我发出的日志" key="2">
                        <Bg_rz_fc/>
                    </TabPane>
                    <TabPane tab="我收到的" key="3">
                        <Bg_rz_sd/>
                    </TabPane>
                    <TabPane tab="未读" key="4">
                        <Bg_rz_wd/>
                    </TabPane>
                </Tabs>
                
            </div>
            <div>
      
                <Modal
                    centered
                    visible={visible}
                    onOk={() =>{fs()}}
                    onCancel={() =>{setVisible(false)} }
                    width={100+'%'}
                    height={100+'%'}
                >
                    <div className="cj">
                        <div>
                            <h2>写日志</h2>
                            <Tabs defaultActiveKey="1" onChange={callback} addIcon={<Button>111111</Button>}>
                
                                <TabPane tab="日报" key="1">
                                    <div style={{height:'100%'}}>
                                        <div className='textarea'>
                                            <p>今日工作内容：</p>
                                            <textarea value={val} onChange={valchange} placeholder="请输入内容"></textarea>
                                        </div>
                                        <div className='textarea'>
                                            <p>明日工作内容：</p>
                                            <textarea value={val1} onChange={valchange1} placeholder="请输入内容"></textarea>
                                        </div>
                                        <div className='textarea'>
                                            <p>遇到的问题：</p>
                                            <textarea value={val2} onChange={valchange2} placeholder="请输入内容"></textarea>
                                        </div>
                                        <p></p>
                                    </div>
                                </TabPane>
                                <TabPane tab="周报" key="2">
                                <div style={{height:'100%'}}>
                                        <div className='textarea'>
                                            <p>本周工作内容：</p>
                                            <textarea value={val} onChange={valchange} placeholder="请输入内容"></textarea>
                                        </div>
                                        <div className='textarea'>
                                            <p>下周工作内容：</p>
                                            <textarea value={val1} onChange={valchange1} placeholder="请输入内容"></textarea>
                                        </div>
                                        <div className='textarea'>
                                            <p>遇到的问题：</p>
                                            <textarea value={val2} onChange={valchange2} placeholder="请输入内容"></textarea>
                                        </div>
                                    </div>
                                </TabPane>
                                <TabPane tab="月报" key="3">
                                <div style={{height:'100%'}}>
                                        <div className='textarea'>
                                            <p>本月工作内容：</p>
                                            <textarea value={val} onChange={valchange} placeholder="请输入内容"></textarea>
                                        </div>
                                        <div className='textarea'>
                                            <p>下月工作内容：</p>
                                            <textarea value={val1} onChange={valchange1} placeholder="请输入内容"></textarea>
                                        </div>
                                        <div className='textarea'>
                                            <p>遇到的问题：</p>
                                            <textarea value={val2} onChange={valchange2} placeholder="请输入内容"></textarea>
                                        </div>
                                    </div>
                                </TabPane>
                            </Tabs>
                        </div>
                    </div>
                </Modal>
            </div>
        </div>
    )
}
export default Bg_rz